package cn.ekuma.epos.pda;

import java.util.Properties;

import cn.ekuma.data.ui.swing.AbstractDAOJEditor;
import com.openbravo.bean.pda.LocalHistory;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Dimension;
import javax.swing.JSplitPane;


public class JLocalHistoryEditor extends AbstractDAOJEditor<LocalHistory>{
	private JTextField txtID;
	private JTextField txtMemo;
	private JTextArea txtCSV;
	private JTextArea txtCSVMore;

	public JLocalHistoryEditor(DirtyManager dirty) {
		super(dirty);
		initComponents();
	}

	
	private void initComponents() {
        setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(10, 50));
		add(panel, BorderLayout.NORTH);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setBounds(23, 10, 81, 15);
		panel.add(lblNewLabel);
		
		txtID = new JTextField();
		txtID.setBounds(105, 10, 102, 21);
		panel.add(txtID);
		txtID.setColumns(10);
		
		txtMemo = new JTextField();
		txtMemo.setBounds(230, 10, 199, 21);
		panel.add(txtMemo);
		txtMemo.setColumns(10);
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		add(splitPane, BorderLayout.CENTER);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		splitPane.setLeftComponent(scrollPane_1);
		
		txtCSVMore = new JTextArea();
		scrollPane_1.setViewportView(txtCSVMore);
		
		JScrollPane scrollPane_2 = new JScrollPane();
		splitPane.setRightComponent(scrollPane_2);
		
		txtCSV = new JTextArea();
		scrollPane_2.setViewportView(txtCSV);
		splitPane.setDividerLocation(100);
		
	}
	
	@Override
	public void refresh() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public LocalHistory createNew(Properties prop) {
		return new LocalHistory();
	}

	@Override
	public void rebuild(LocalHistory obj) throws BasicException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateUI(boolean editAble, int state) {
		txtID.setText(this.obj.getId());
		txtMemo.setText(obj.getLocalMachineName()+":"+obj.getMemo());
		txtCSV.setText(obj.getCsvValue());
		txtCSVMore.setText(obj.getCsvMore());
		
		txtMemo.setEditable(false);
		txtID.setEditable(false);
		txtCSV.setEditable(editAble);
		txtCSVMore.setEditable(false);
	}

	@Override
	public Class getEditClass() {
		return LocalHistory.class;
	}
}
